﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SARUserControls
{
	/// <summary>
	/// 分栏条控件
	/// </summary>
	public partial class SubfieldBar : UserControl
	{
		public SubfieldBar()
		{
			this.InitializeComponent();
		}

        /// <summary>
        /// 标题
        /// </summary>
        public string SARTitle
        {
            set
            {
                this.txtTitle.Text = value;
            }
            get
            {
                return this.txtTitle.Text;
            }
        }

        private bool isUnfolded = true;

        /// <summary>
        /// 标题旁边的三角符号是否显示为展开
        /// </summary>
        public bool SARIsUnfolded
        {
            set
            {
                isUnfolded = value;
                if (value)
                {
                    pathUnfoldedStatus.Visibility = System.Windows.Visibility.Visible;
                    pathFoldedStatus.Visibility = System.Windows.Visibility.Hidden;
                }
                else
                {
                    pathUnfoldedStatus.Visibility = System.Windows.Visibility.Hidden;
                    pathFoldedStatus.Visibility = System.Windows.Visibility.Visible;
                }
            }
            get
            {
                return isUnfolded;
            }
        }

        /// <summary>
        /// 单击事件，需要界面组装人员完成切换工作。
        /// </summary>
        public event MouseButtonEventHandler SARClick;
        private void gridMouseCapture_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (SARClick != null)
            {
                SARClick.Invoke(this, e);
            }
        }

        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (SARClick != null)
            {
                SARClick.Invoke(this, e);
            }
        }       
	}  
}